<template>
	<view>
		<u-swiper :list="swiperImg" mode="dot" height="600" interval="3000" :circular="true"></u-swiper>
		<view class="" style="padding:15rpx 30rpx;margin-bottom: 20rpx;background-color: #fff;">
			<text style="color: red;font-size: 48rpx;">￥{{goodsDetail.actualPrice}}</text>
			<text class="del-price">￥{{goodsDetail.originalPrice}}</text>
			<text style="float: right;margin-top: 25rpx;color: #888;">月销量：{{goodsDetail.monthSales}}</text>
			<text class="goods-title"><text class="m-tag-mr">淘</text>{{goodsDetail.title}}</text>
			<!-- <navigator url="/pages/index/index">{{goodsDetail.couponLink}}</navigator> -->
			<view @click="show = true" class="coupon-b"
				style="background-image: url(https://api.gold404.cn/taoke/images/coupon-b.png);">
				<view>
					<text style="font-size: 54rpx;display: block;">￥{{goodsDetail.couponPrice}}</text>
					<text class="coupon-time">使用期限 {{goodsDetail.couponStartTime}}~{{goodsDetail.couponEndTime}}</text>
				</view>
				<text class="coupon-text">立即领券</text>
			</view>
		</view>
		<view class="" style="background-color: #fff;padding: 30rpx;margin-bottom: 20rpx;">
			<u-icon name="shopping-cart-fill" color="#ff0000" size="35"></u-icon>
			<text style="margin-left: 5px;">{{goodsDetail.shopName}}</text>
		</view>
		<view class="" style="padding: 30rpx;background-color: #fff;">
			<u-divider>商品详情</u-divider>
			<view class="" style="margin-top: 80rpx;">
				<u-empty text="没有找到相关数据哦!" mode="list"></u-empty>
			</view>
		</view>
		<u-popup v-model="show" mode="center" border-radius="8" width="80%" :closeable="true"
			close-icon-color="#f35c04">
			<view class="kouling-box">
				<text style="display: block;margin-top: 10rpx;">复制淘口令购买</text>
				<view class="kouling-text" style="">
					<text>{{tkouling}}</text>
				</view>
				<button type="warn" size="mini" @click="copy">一键复制</button>
			</view>
		</u-popup>

		<view class="bottom-nav u-flex u-row-between">
			<u-icon label="收藏" label-pos="bottom" size="40" label-size="24" name="star"></u-icon>
			<view class="nav-view u-flex">
				<button type="default" plain="true">分享赚 ￥9.88</button>
				<button type="default" plain="true" @click="toCoupon">自购省 ￥4.5</button>
			</view>
		</view>
		<view style="height: 96rpx;margin-top: 20rpx;"></view>
	</view>
</template>

<script>
	import uniCopy from '@/js_sdk/xb-copy/uni-copy.js'
	export default {
		data() {
			return {
				show: false,
				goodsDetail: [],
				tkouling:'淘口令生成失败！',
				swiperImg: []
			}
		},
		onLoad: function(option) {
			uni.showLoading({
				title:'加载中'
			})
			this.$myRequest('/goodsDetail',{id: option.id}).then(res=>{
				this.goodsDetail = res.data
				this.goodsDetail.couponStartTime = res.data.couponStartTime.substr(0, 10)
				this.goodsDetail.couponEndTime = res.data.couponEndTime.substr(0, 10)
				this.swiperImg = this.goodsDetail.imgs.split(',')
				this.tkouling=res.data.changeLink.data.longTpwd
				uni.hideLoading();
				// console.log(res.data.changeLink.data)
			})
		},
		methods: {
			toCoupon() {
				uni.navigateTo({
					url: 'https://uland.taobao.com/quan/detail?sellerId=3048974064&activityId=a8c114d6fe834786a648790503ccb2a1'
				})
			},
			copy() {
				uniCopy({
					content: this.tkouling,
					success: (res) => {
						console.log(res)
					},
					error: (err => {
						console.log(err)
					})
				})
				// uni.setClipboardData({
				// 	data:'你大爷',
				// 	success:()=>{
				// 		console.log(res)
				// 	}
				// })
			}
		}
	}
</script>

<style scoped>
	.icon {
		width: 1em;
		height: 1em;
		vertical-align: -0.15em;
		fill: currentColor;
		overflow: hidden;
	}

	.goods-title {
		display: block;
		font-size: 32rpx;
	}

	.coupon-b {
		margin: 20rpx 0;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		height: 130rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		color: #fff;
	}

	.coupon-text {
		font-size: 32rpx;
		letter-spacing: 2rpx;
		margin-right: 22rpx;
	}

	.coupon-time {
		color: rgba(255, 255, 255, 0.67);
		font-size: 24rpx;
	}

	.kouling-box {
		width: 100%;
		height: 100%;
		padding: 20rpx;
		text-align: center;
		/* border-radius: 10px; */
	}

	.kouling-text {
		text-align: left;
		margin: 30rpx 0;
		background-color: #f7dfad;
		padding: 30rpx;
		border-radius: 5px;
		border: 1px solid #ff0000;
	}

	.bottom-nav {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 96rpx;
		border-top: 1px solid #f7f7f7;
		padding: 0 20rpx;
		background-color: #fff;
	}

	.nav-view button:first-child {
		background-color: #ffb622;
		border-radius: 2em 0 0 2em;
	}

	.nav-view button {
		color: #fff;
		font-weight: 600;
		border: none;
		font-size: 28rpx;
		border-radius: 0;
		background-color: #ff8295;
		border-radius: 0 2em 2em 0;
	}
</style>
